#pragma once
#include <d3dx9.h> 
#include <strsafe.h>
#include "GameState.h"
#include "SimpleRender.h"
#include "HavokWorld.h"
#include "PhysicsDemo.h"




	class GameLoop
	{
	public:

		void Run()
		{
			TheGameStateManager::Get().Init();
			TheGameStateManager::Get().SetGameState(new PhysicsDemo());
			//	TheGameStateManager::Get().SetGameState(new Drawing2DDemo());

			//TheGameStateManager::Get().SetGameState(new PengGameState(new pengGames::GameState_Menu()));
			//SimpleRender::Get().Set2DProjection();
			//TheGameStateManager::Get().SetGameState(new NikosGameState(new NikosGames::MainMenuState()));
			// Enter the message loop
			MSG msg;
			ZeroMemory( &msg, sizeof( msg ) );
			while( msg.message != WM_QUIT )
			{
				if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
				{
					TranslateMessage( &msg );
					DispatchMessage( &msg );
				}
				else
				{
					if(!TheGameStateManager::Get().Update())
					{
						PostQuitMessage(0);
					}

					TheGameStateManager::Get().Render();
				}

			}
			
			TheGameStateManager::Kill();
			SimpleRender::Kill();
			HavokWorld::Kill();
		}



	};

